#pragma once
#ifndef EDITOR__SETTINGS__TAB__WIDGET__HH__
#define EDITOR__SETTINGS__TAB__WIDGET__HH__

#include "LitEditorPrerequisites.h"
#include "ui_SettingsTableWidget.h"
#include <qtablewidget.h>
#include <qtabwidget.h>
#include "LitEditorSettingsWidget.h"

namespace Lit
{
	namespace Editor
	{
		class LIT_API SettingsTableWidget : public QWidget
		{
			Q_OBJECT

		protected slots:
			void _itemChanged( const QString &name, const QString & val );
		signals:
			void itemChanged( const std::string &page, const std::string &name, const std::string &val );

		protected:
			SettingsMap					mItems;
			std::unordered_map<std::string, SettingsItemWidget*> mWidgets;

			Ui::SettingsTableWidget		mUi;
			std::string					mName;
		public:
			SettingsTableWidget( QWidget * parent, const std::string &name );
			~SettingsTableWidget();

			SettingsMap& getSettings();
			const SettingsMap& getSettings() const;

			const std::string &getName() const;

			const Ui::SettingsTableWidget& getUi() const;
			Ui::SettingsTableWidget& getUi();

			SettingsItemWidget* _createSettingByType( const SettingsValue& val );
			void setupUi( const SettingsMap& settings );
		};

		class LIT_API SettingsTabWidget : public QTabWidget
		{
			std::unordered_map<std::string, SettingsTableWidget*> mPages;
		public:
			SettingsTabWidget( QWidget * parent );
			~SettingsTabWidget( );

			SettingsTableWidget* addPage( const std::string &name );
			void clearPages( );
			void removePage( const std::string &name );
		};
	};
};

#endif